package com.yc.service.miniapp.Impl;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yc.dao.DaoSupport;
import com.yc.util.PageData;

@Service("appUserInfoServiceImpl")
public class AppUserInfoServiceImpl {

	@Resource(name = "daoSupport")
	private DaoSupport dao;
	/**
	 * 获取登录用户  根据userName
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public PageData findLoginUser(PageData pd) throws Exception {
		return (PageData)dao.findForObject("AppUserInfoMapper.findLoginUser", pd);
	}
	/**
	 * 获取登录用户  根据email
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public PageData findLoginUserByEmail(PageData pd) throws Exception {
		return (PageData)dao.findForObject("AppUserInfoMapper.findLoginUserByEmail", pd);
	}
	
	public void register(PageData pd) throws Exception{
		dao.findForObject("AppUserInfoMapper.save", pd);
	}
	
	public void updateLastLogin(PageData pd) throws Exception{
		dao.findForObject("AppUserInfoMapper.updateLastLogin", pd);
	}
	
	/**
	 * 根据名称查询用户存在数量
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public PageData findNumByName(PageData pd) throws Exception {
		return (PageData)dao.findForObject("AppUserInfoMapper.findNumByName", pd);
	}

	/**
	 * 根据邮箱查询用户存在数量
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public PageData findNumByEmail(PageData pd) throws Exception {
		return (PageData)dao.findForObject("AppUserInfoMapper.findNumByEmail", pd);
	}

	public PageData findUserById(PageData pd) throws Exception {
		return (PageData)dao.findForObject("AppUserInfoMapper.findUserById", pd);
	}
	
	/**
	 * 修改用户信息
	 * @param pd
	 * @throws Exception
	 */
	public void updateUserInfo(PageData pd) throws Exception{
		dao.findForObject("AppUserInfoMapper.updateUserInfo", pd);
	}
	
	
	@SuppressWarnings("unchecked")
	public List<PageData> testGetUsers(PageData pd) throws Exception{
		return (List<PageData>) dao.findForList("AppUserInfoMapper.testgetalluser", pd);
	}
	
}
